Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Predict the output?#include <stdio.h>in... Start Learning for Free
Predict the output?
#include <stdio.h>
int main()
{
    void demo();
    void (*fun)();
    fun = demo;
    (*fun)();
    fun();
    return 0;
}
void demo()
{
    printf("EduRevQuiz ");
}
  • a)
    EduRevQuiz
  • b)
    EduRevQuiz EduRevQuiz
  • c)
    Compiler Error
  • d)
    Blank Screen
Correct answer is option 'B'. Can you explain this answer?
Most Upvoted Answer
Predict the output?#include <stdio.h>int main(){ void demo(); ...


Explanation:

Function Pointers:
- In this program, there is a function pointer `fun` declared and initialized with the address of the function `demo`.
- Function pointers are used to store the address of functions and can be used to call the function indirectly.

Calling the Function using Function Pointer:
- The function `demo` is defined to print "EduRevQuiz".
- The function pointer `fun` is dereferenced and called in two ways:
- `(*fun)();` // Dereferencing the function pointer and calling the function
- `fun();` // Directly calling the function pointer, which is equivalent to the above line

Output:
- So, when the function pointer is called, it will print "EduRevQuiz" twice because the function `demo` is called twice using the function pointer.

Therefore, the output of this program will be:
EduRevQuizEduRevQuiz
Free Test
Community Answer
Predict the output?#include <stdio.h>int main(){ void demo(); ...
This is a simple program with function pointers. fun is assigned to point to demo. So the two statements "(*fun)();" and "fun();" mean the same thing.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Predict the output?#include <stdio.h>int main(){ void demo(); void (*fun)(); fun = demo; (*fun)(); fun(); return 0;}void demo(){ printf("EduRevQuiz ");}a)EduRevQuizb)EduRevQuizEduRevQuizc)Compiler Errord)Blank ScreenCorrect answer is option 'B'. Can you explain this answer?
Question Description
Predict the output?#include <stdio.h>int main(){ void demo(); void (*fun)(); fun = demo; (*fun)(); fun(); return 0;}void demo(){ printf("EduRevQuiz ");}a)EduRevQuizb)EduRevQuizEduRevQuizc)Compiler Errord)Blank ScreenCorrect answer is option 'B'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about Predict the output?#include <stdio.h>int main(){ void demo(); void (*fun)(); fun = demo; (*fun)(); fun(); return 0;}void demo(){ printf("EduRevQuiz ");}a)EduRevQuizb)EduRevQuizEduRevQuizc)Compiler Errord)Blank ScreenCorrect answer is option 'B'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Predict the output?#include <stdio.h>int main(){ void demo(); void (*fun)(); fun = demo; (*fun)(); fun(); return 0;}void demo(){ printf("EduRevQuiz ");}a)EduRevQuizb)EduRevQuizEduRevQuizc)Compiler Errord)Blank ScreenCorrect answer is option 'B'. Can you explain this answer?.
Solutions for Predict the output?#include <stdio.h>int main(){ void demo(); void (*fun)(); fun = demo; (*fun)(); fun(); return 0;}void demo(){ printf("EduRevQuiz ");}a)EduRevQuizb)EduRevQuizEduRevQuizc)Compiler Errord)Blank ScreenCorrect answer is option 'B'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of Predict the output?#include <stdio.h>int main(){ void demo(); void (*fun)(); fun = demo; (*fun)(); fun(); return 0;}void demo(){ printf("EduRevQuiz ");}a)EduRevQuizb)EduRevQuizEduRevQuizc)Compiler Errord)Blank ScreenCorrect answer is option 'B'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Predict the output?#include <stdio.h>int main(){ void demo(); void (*fun)(); fun = demo; (*fun)(); fun(); return 0;}void demo(){ printf("EduRevQuiz ");}a)EduRevQuizb)EduRevQuizEduRevQuizc)Compiler Errord)Blank ScreenCorrect answer is option 'B'. Can you explain this answer?, a detailed solution for Predict the output?#include <stdio.h>int main(){ void demo(); void (*fun)(); fun = demo; (*fun)(); fun(); return 0;}void demo(){ printf("EduRevQuiz ");}a)EduRevQuizb)EduRevQuizEduRevQuizc)Compiler Errord)Blank ScreenCorrect answer is option 'B'. Can you explain this answer? has been provided alongside types of Predict the output?#include <stdio.h>int main(){ void demo(); void (*fun)(); fun = demo; (*fun)(); fun(); return 0;}void demo(){ printf("EduRevQuiz ");}a)EduRevQuizb)EduRevQuizEduRevQuizc)Compiler Errord)Blank ScreenCorrect answer is option 'B'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Predict the output?#include <stdio.h>int main(){ void demo(); void (*fun)(); fun = demo; (*fun)(); fun(); return 0;}void demo(){ printf("EduRevQuiz ");}a)EduRevQuizb)EduRevQuizEduRevQuizc)Compiler Errord)Blank ScreenCorrect answer is option 'B'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev